package com.zaizai.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * 商品详情对象 commodity
 *
 * @author zaiZai
 * @date 2024-10-21
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = false)
public class Commodity extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 主键 */
    private Long id;

    /** 产品名称 */
    private String name;

    /** 产品编号（自动生成）*/
    private String serialNumber;

    /** 所属分类 */
    private Long typeId;



    /** 库存数量 */
    private Long inventory;

    /** 产品价格，单位分 */
    private Long price;

    /** 图片 */
    private String images;

    /** 是否上架 */
    private Integer isShelves;

    /** 是否推荐 */
    private Integer isRecommend;

    /** 是否首页推荐 */
    private Integer isHome;

    /** 备注 */
    private String remark;

    // 搜索参数字段，不映射到数据库
    @TableField(exist = false)
    private String beginTime;
    
    @TableField(exist = false)
    private String endTime;
    
    @TableField(exist = false)
    private Long minPrice;
    
    @TableField(exist = false)
    private Long maxPrice;
    
    @TableField(exist = false)
    private String stockFilter; // 库存过滤条件：low/high

    // 添加新字段用于库存范围查询
    @TableField(exist = false)
    private Long minInventory;

    @TableField(exist = false)
    private Long maxInventory;

    @TableField(exist = false)
    private String idsStr; // 添加字符串形式的ID列表

    @TableField(exist = false)
    private Long[] ids;  // 修改为 Long[] 类型

    @TableField(exist = false)
    private List<Long> idList;  // 用于按ID列表查询

    /** 分页大小 */
    @TableField(exist = false)
    private Integer pageSize;

    /** 页码 */
    @TableField(exist = false)
    private Integer pageNum;

    public void setIds(Long[] ids) {
        this.ids = ids;
    }

    public Long[] getIds() {
        return ids;
    }

    public String getIdsStr() {
        return idsStr;
    }

    public void setIdsStr(String idsStr) {
        this.idsStr = idsStr;
    }
}
